{include file='./inc/header.tpl'}
<div id="wrap">
    {include file='./inc/head.tpl'}
    <div id="contents">
        <div class="ttl">
            <h2>求人一覧</h2>
        </div>
        {include file='./inc/message.tpl'}
        <div class="menuArea">
            <div class="btn primary open" style="float: left;">検索</div>
            <div class="btn primary" onclick="location.href='./admin/job_edit'">新規登録</div>
            <div class="slideBox searchBox">
                <h3>検索</h3>
                <form name="search_form" id="search_form" method="post" action="./admin/job">
                    <input type="hidden" name="transid" value="{$transactionid}">
                    <input type="hidden" name="mode" value="search">
                    <dl>
                        <dt>仕事コード</dt>
                        <dd>
                            {assign var=key value="search_job_code"}
                            <input type="text" name="{$key}" value="{$arrForm[$key].value}" size="10" {if !empty($arrErr[$key].error)}class="attentionBg"{/if} />
                            {if !empty($arrErr[$key].error)}
                                <div class="attention">{$arrErr[$key].error}</div>
                            {/if}
                        </dd>
                        <dt>タイトル</dt>
                        <dd>
                            {assign var=key value="search_job_title"}
                            <input type="text" name="{$key}" value="{$arrForm[$key].value}" size="30" {if !empty($arrErr[$key].error)}class="attentionBg"{/if} />
                            {if !empty($arrErr[$key].error)}
                                <div class="attention">{$arrErr[$key].error}</div>
                            {/if}
                        </dd>
                        <dt>カテゴリ</dt>
                        <dd>
                            {assign var=key value="search_category_id"} {html_options class="selectField" name=$key options=$config.default_all+$category selected=$arrForm[$key].value}
                            {if !empty($arrErr[$key].error)}
                                <div class="attention">{$arrErr[$key].error}</div>
                            {/if}
                        </dd>
                        <dt>地域</dt>
                        <dd>
                            {assign var=key value="search_pref_id"} {html_options name=$key options=$config.default_all+$config.pref selected=$arrForm[$key].value}
                            {if !empty($arrErr[$key].error)}
                                <div class="attention">{$arrErr[$key].error}</div>
                            {/if}    
                        </dd>
                        <dt>経験</dt>
                        <dd>
                            {assign var=key value="search_experience"}
                            <input type="text" name="{$key}" value="{$arrForm[$key].value}" size="10" {if !empty($arrErr[$key].error)}class="attentionBg"{/if}/>
                            {if !empty($arrErr[$key].error)}
                                <div class="attention">{$arrErr[$key].error}</div>
                            {/if}
                        </dd>
                    </dl>
                    <input class="primary" type="submit" value="検索" />
                </form>
            </div>
        </div>
        {if !empty($job)}
        <form action="./admin/job" id="form1" name="form1" method="post">
            <input type="hidden" name="transid" value="{$transactionid}">
            <input type="hidden" name="mode" value="search" />
            <input type="hidden" name="job_id" value="">
            <!--{foreach from=$arrHidden key="key" item="item"}-->
            <!--{if is_array($item)}-->
            <!--{foreach item=c_item from=$item}-->
            <input type="hidden" name="{$key}[]" value="{$c_item}" />
            <!--{/foreach}-->
            <!--{else}-->
            <input type="hidden" name="{$key}" value="{$item}" />
            <!--{/if}-->
            <!--{/foreach}-->
            <table>
                <thead>
                    <th class="tC">仕事コード</th>
                    <th class="tC">タイトル</th>
                    <th class="tC">カテゴリ</th>
                    <th class="tC">地域</th>
                    <th class="tC">経験</th>
                    <th class="tR">給与</th>
                    <th class="tC"></th>
                </thead>
               結果：{$job_cnt}件
                <br />
                <br />
                <tbody align="center">
                    {foreach from=$job item=item name=count}
                    <tr class="selectTarget {if ($smarty.foreach.count.index +1) % 2 == 0}even{/if}">
                        <td>{$item.job_code}</td>
                        <td>{$item.content_title|nl2br}</td>
                        <td>{if !empty($category[$item.category_id])}{$category[$item.category_id]}{/if}</td>
                        <td>
                            {foreach $config.pref as $place}
                                {if !empty($place[$item.pref_id])}
                                    {$place[$item.pref_id]}
                                    {break}
                                {/if}
                            {/foreach}
                        </td>
                        <td>{if $item.experience != ''}{$item.experience}{else}なし{/if}</td>
                        <td align="right">{$item.salary}</td>
<!--                         <td>{$item.regist_datetime}</td> -->
                        <!--                     <td>{$item.lastup_datetime}</td> -->
                        <td><a href="javascript:;" onclick="edit({$item.job_id});">
                                <span class="btn">編集</span>
                            </a> <a href="javascript:;" onclick="submitForm('form1','delete','job_id',{$item.job_id});">
                                <span class="btn">削除</span>
                            </a></td>
                    </tr>
                    {/foreach}
                </tbody>
            </table>
            <div class="pager">
                <ul>{$pager}
                </ul>
            </div>
        </form>
        {else}
        <div style="color: red;">データがありません。</div>
        {/if}
    </div>
    <!-- #contents -->
</div>
<!-- #wrap -->
<link rel="stylesheet" href="css/jquery-ui.css">
<script type="text/javascript">
$(document).ready(function($) {

	$('.datepicker').datepicker({ dateFormat: "yy-mm-dd" });
    $('.open').click(function(){
        $(this).parent().find( "div.slideBox" ).stop(true, true).slideToggle("fast");
    });

    $(".specify").change(function() {
    var specify = 1;
    var tmp = $(this).attr("class").split(" ");
    $("#" + tmp[1]).css("display", ($(this).val() == specify ? "" : "none"));
    });

    $(".selectField").change(function() {
        $("#field").find("option:gt(0)").remove();
        var category_id = $(this).val();
        $.ajax({
            url: "/selectField",
            method: "GET",
            async: false,
            data: ({ id : category_id }),
            dataType: 'json',
            success: function(data) {
                if(data != 'NG') {
                    var htmlStr = '';
                    $.each(data, function(k, v){
                        htmlStr += '<option value="'+v.field_id+'">'+v.field_name+'</option>';
                    });
                    $("#field").append(htmlStr);
                }
            }
        });
    });
});
function edit(id){
    document.form1.action = './admin/job_edit';
    document.form1['job_id'].value = id;
    document.form1['mode'].value = 'pre_edit';
    document.form1.submit();
}
</script>
{include file='./inc/footer.tpl'}
